import request from '@/utils/request'
import type { ModelForm, ModelDesignVo } from '@/types/process'

// 获取流程模型列表
export function getFlowModels(params: {
  pageNo: number
  pageSize: number
  name?: string
  category?: string
}) {
  return request({
    url: '/model/list',
    method: 'get',
    params,
  })
}

// 创建流程模型
export function createFlowModel(data: ModelForm) {
  return request({
    url: '/model/create',
    method: 'post',
    data,
  })
}

// 更新流程模型
export function updateFlowModel(data: ModelForm) {
  return request({
    url: '/model/update',
    method: 'post',
    data,
  })
}

// 获取流程模型详情
export function getFlowModelById(id: string) {
  return request({
    url: `/model/${id}`,
    method: 'get',
  })
}

// 部署流程模型
export function deployModel(id: string) {
  return request({
    url: `/model/deploy/${id}`,
    method: 'post',
  })
}

// 删除流程模型
export function deleteModel(id: string) {
  return request({
    url: `/model/delete/${id}`,
    method: 'post',
  })
}

//流程设计接口
export function modelDesign(data: ModelDesignVo) {
  return request({
    url: `/model/design`,
    method: 'post',
    data,
  })
}

// 查询流程定义
export function getProcessDefinitions(key: string) {
  return request({
    url: `/process/definition/${key}`,
    method: 'get',
  })
}
